package com.example.networkinteraction.util;

import android.support.v4.app.NotificationCompat;
import com.example.networkinteraction.api.ApiFactory;
import com.example.networkinteraction.customclient.CustomOkHttpClient;

/**
 * Description:
 * File: RxUtil.java
 * Author: Administrator
 * Create: 2019/3/30 0030 上午 9:40
 */
public enum RxUtil {
    INSTANCE;

    public static RxUtil getInstance() {
        return INSTANCE;
    }

    public <K> K createApi(Class<K> cls) {
        return ApiFactory.getInstance().createApi(cls);
    }

    /**
     * 可以通过它来创建API
     *
     * @param baseUrlKey   域名的Key
     * @param baseUrlValue 域名的url
     * @param cls
     * @param <K>          API接口
     * @return
     */
    public <K> K createApi(String baseUrlKey, String baseUrlValue, Class<K> cls) {
        return ApiFactory.getInstance().createApi(baseUrlKey, baseUrlValue, cls);
    }

    /**
     * 全局ApiFactory 的配置
     *
     * @return
     */
    public ApiFactory config() {
        return ApiFactory.getInstance();
    }

    public void setCustomOkHttpClient() {
        ApiFactory.getInstance().setOkClient(CustomOkHttpClient.getInstance().getOkHttpClient());
    }
}
